using System;
using System.Collections.Generic;
using System.Text;
using Mud.Common.Messages;
using Mud.Server.Physical;

namespace Mud.Server
{

    /// <summary>
    /// Maps some server objects to messages.
    /// </summary>
    public static class ObjectToMessageMapper {

        /// <summary>
        /// Maps the physical object to message for transmission.
        /// </summary>
        /// <param name="mapper">Creature that is doing the mapping, 
        /// depending on the mapper, more or less information will be available.</param>
        /// <param name="o">Object to map.</param>
        /// <returns>Message.</returns>
        public static MessageStructurePhysicalObjectInfo MapToMessage(Creature mapper, PhysicalObject o)
        {
            MessageStructurePhysicalObjectInfo msg = new MessageStructurePhysicalObjectInfo();
            msg.AreaName = o.CurrentAreaName;
            msg.LocationX = o.Location.X;
            msg.LocationY = o.Location.Y;
            msg.ObjectId = o.ObjectId;
            msg.ObjectName = o.Name;
            msg.Orientation = o.PhysicalProperties.Orientation;
            
            return msg;
        }

        /// <summary>
        /// Maps the creature to message for transmission.
        /// </summary>
        /// <param name="mapper">Creature that is doing the mapping, 
        /// depending on the mapper, more or less information will be available.</param>
        /// <param name="o">Creature to map.</param>
        /// <returns>Message.</returns>
        public static MessageStructureCreatureInfo MapToMessage(Creature mapper, Creature c)
        {
            MessageStructurePhysicalObjectInfo msgObject = MapToMessage(mapper, (PhysicalObject)c);
            MessageStructureCreatureInfo msgCreature = new MessageStructureCreatureInfo();
            msgCreature.ObjectInfo = msgObject;
            return msgCreature;
        }

        /// <summary>
        /// Maps the simple object to message for transmission.
        /// </summary>
        /// <param name="mapper">Creature that is doing the mapping, 
        /// depending on the mapper, more or less information will be available.</param>
        /// <param name="o">Creature to map.</param>
        /// <returns>Message.</returns>
        public static MessageStructureSimpleObjectInfo MapToMessage(Creature mapper, SimpleObject c)
        {
            MessageStructurePhysicalObjectInfo msgObject = MapToMessage(mapper, (PhysicalObject)c);
            MessageStructureSimpleObjectInfo msgCreature = new MessageStructureSimpleObjectInfo();
            msgCreature.ObjectInfo = msgObject;
            return msgCreature;
        }

    }

}
